class Solution
{
public:
    vector<int> targetIndices(vector<int> &nums, int target)
    {
        sort(nums.begin(), nums.end());
        int n = nums.size();
        int i = 0;
        vector<int> result;
        while (i < n && nums[i] != target)
        {
            ++i;
        }
        while (i < n && nums[i] == target)
        {
            result.push_back(i);
            ++i;
        }
        return result;
    }
};